package com.itheima.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.commit.R;
import com.itheima.dto.SetmealDto;
import com.itheima.pojo.Setmeal;
import com.itheima.pojo.SetmealDish;
import com.itheima.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Autowired
    private SetmealService setmealService;

    @PostMapping
    public R<String> add(@RequestBody SetmealDto setmealDto){
        return setmealService.add(setmealDto);
    }

    @GetMapping("/page")
    public R<IPage> selectAll(Integer page, Integer pageSize, String name){
        return setmealService.selectAll(page,pageSize,name);
    }
    @DeleteMapping
    public R<String> delete(Long[] ids){
        return setmealService.delete(ids);
    }
    @PostMapping("/status/{s}")
    public R<String> upda(@PathVariable Integer s,Long[] ids){
        return setmealService.upda(s,ids);
    }
    @GetMapping("/{id}")
    public R<SetmealDto> get(@PathVariable Long id){
        return setmealService.get(id);
    }
    @PutMapping
    public R<String> update(@RequestBody SetmealDto setmealDto){
        return setmealService.update(setmealDto);
    }
    @GetMapping("/list")
    public R<List<Setmeal>> list(Setmeal setmeal){
        return setmealService.list(setmeal);
    }
    @GetMapping("/dish/{id}")
    public R<List<Setmeal>> dish(@PathVariable Long id){
        return setmealService.dish(id);
    }
}
